package demo.collection;

import general.InterfaceCollection;

import java.util.ArrayList;
import java.util.Iterator;

public class GenericTest implements InterfaceCollection {

	@Override
	public void run() {
		ArrayList<MyClass<String, Integer>> myList = new ArrayList<MyClass<String, Integer>>();
		Integer I1 = new Integer(1);
		String p = new String("ready");
		MyClass<String, Integer> mc1 = new MyClass<String, Integer>(p, I1);
		MyClass<String, Integer> mc2 = new MyClass<String, Integer>("set", new Integer("2"));
		MyClass<String, Integer> mc3 = new MyClass<String, Integer>("go", new Integer("3"));
		myList.add(mc1);
		myList.add(mc2);
		myList.add(mc3);
		MyClass<String, Integer> mc = new MyClass<String, Integer>();
		Iterator<MyClass<String, Integer>> itr = myList.iterator();
		while (itr.hasNext()) {
			mc = itr.next();
			Integer I = (Integer) mc.getS();
			int i = I.intValue();
			System.out.println(mc.getP() + " " + i);
		}
		
		MyClass<Integer, String> mcasd = new MyClass<Integer, String>(I1, p);
		System.out.println(mcasd.getS());
		
	}
}

class MyClass<P, S> {
	private P pvar;
	private S svar;

	MyClass() {
	}

	MyClass(P pvar, S svar) {
		this.pvar = pvar;
		this.svar = svar;
	}

	public P getP() {
		return pvar;
	}

	public S getS() {
		return svar;
	}
}
